<template>
  <div>
    <cus-modal
      ref="modal"
      title="物资领用单详情"
      :width="1500"
    >
    <cus-search style="min-width: 1200px; padding-bottom: 0">
      <cus-search-item>
        <Form
          :model="form"
          :label-width="80"
          ref="formValidate"
          @keydown.native.enter.prevent="onInit"
        >
        <FormItem label="物资名称" :label-width="80" class="mr_48 mb_20">
            <Input
              v-model="form.productName"
              placeholder="请输入物资名称"
            />
            </FormItem>
     
          <cusButton
            class="mr_20 mb_20"
            type="primary"
            @onClick="
              pages.page = 1;
              postApiReceiveorderGetApi();
            "
            >查询</cusButton
          >
        </Form>
      </cus-search-item>
    </cus-search>
      <Table border :loading="loading" :columns="columns" :data="data" :size="vuex_config.tableSize" class="mt_20">
      </Table>
       <div class="mt_10" v-if="data.length>0" style="margin-bottom:-20px;">
        <cus-page :data="pages" class="mt_10 flex_jd" @pageChange="postApiReceiveorderGetApi"></cus-page>
      </div>
      <div slot="footer">
        <slot name="footer">
        </slot>
      </div>
    </cus-modal>
  </div>
</template>

<script>
import { postApiReceiveorderGet } from "@/api/business/manager";

const columns = [
  {
    //菜肴属性维护Table表头数据
    title: "序号",
    type: "index",
    width: 65,
    align: "center",
  },
  {
    title: "物资名称",
    minWidth: 103,
    key: "productName",
    align: "center",
  },{
    title: "存储仓库",
    minWidth: 95,
    key: "stockName",
    align: "center",
  },{
    title: "领用单号",
    minWidth: 110,
    key: "billNo",
    align: "center",
  }, {
    title: "领用人",
    minWidth: 80,
    key: "poinventroyName",
    align: "center",
  },{
    title: "库存数量",
    minWidth: 95,
    key: "originalNum",
    align: "center",
  },{
    title: "领用数量",
    minWidth: 95,
    key: "packagingQty",
    align: "center",
  },{
    title: "计量单位",
    minWidth: 95,
    key: "packagingUtil",
    align: "center",
  },{
    title: "单价(元)",
    minWidth: 70,
    key: "packagingPrice",
    align: "center",
  },{
    title: "单位重量(Kg)",
    minWidth: 125,
    key: "unitWeight",
    align: "center",
  },{
    title: "金额(元)",
    minWidth: 95,
    key: "amount",
    align: "center",
  }
];
export default {
  components: {},
  data() {
    return {
      loading: false,
      form: {
        id: "",
         productName: "" // 物资名称
      },
      columns,
      data: [],
      pages: {
        page: 1,
        pageSize: 10,
        pageTotal: 0,
      },
    };
  },

  mounted() {

  },
  methods: {
    show(id) {
      // 清空源数据
      Object.assign(this.$data, this.$options.data())
      this.loading = false;
      this.form.id = id
      this.$refs["modal"].show = true;
      this.postApiReceiveorderGetApi();
    },
    // 模态框确认
    onOk() {
    },
    // 取消
    onCancel() {
      this.$refs["modal"].show = false;
    },
    // 物资领用单详情-------------接口
    postApiReceiveorderGetApi() {
      this.loading = true
        return new Promise((resolve) => {
        let params = {
          id: this.form.id,
          productName: this.form.productName,
          current: this.pages.page,
          size: this.pages.pageSize,
        };
        postApiReceiveorderGet(params).then((res) => {
          this.loading = false
          if (res.retCode === 2000) {
              this.data = res.data.records;
              this.pages.pageTotal = res.data.total;
            resolve();
          } 
        });
      });
    }
  },
};
</script>

<style scoped>
</style>
